<%--
  Created by IntelliJ IDEA.
  User: lingshao
  Date: 2020/9/15
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>试卷信息表</title>
    <link rel="stylesheet" href="../layui/layui/css/layui.css" media="all">

    <script src="../layui/layui/layui.js"></script>
</head>
<body>

<blockquote class="layui-elem-quote news_search">
    <%--头部搜索功具栏--%>
    <div id="demoTable" hidden="true">
        <div class="layui-inline">
            <input style="width: 220px;height: 30px; border-radius: 10px" placeholder="请输入试卷编号" class="layui-input" name="id" id="demoReload">
        </div>
        <div class="layui-inline">
            <input style="width: 220px;height: 30px; border-radius: 10px" placeholder="请输入班级编号" class="layui-input" name="id" id="demoone">
        </div>
        <button class="layui-btn layui-btn-radius layui-btn-normal" >搜索</button>
    </div>
    <%--显示页面--%>
    <table id="demo" lay-filter="test"></table>
</blockquote>

<%--侧边功具栏:进入考试--%>
<div id="barDemo" hidden="true" lay-filter="test">
    <button class="layui-btn layui-btn-sm layui-btn-radius" lay-event="into">进入考试</button>
</div>

    <script>
        layui.use('table', function(){
            var table = layui.table;

            //第一个实例
            table.render({
                elem: '#demo'
                ,cellMinWidth: 80
                ,toolbar:"#demoTable"
                ,height:560
                ,defaultToolbar:['filter', 'print', 'exports']
                ,url: '../json/Paper.json' //数据接口
                , limits: [5,10,15,20]  //一页选择显示3,5或10条数据
                , limit: 5  //一页显示10条数据
                , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据，res为从url中get到的数据
                    var result;
                    console.log(this);
                    console.log(JSON.stringify(res));
                    if (this.page.curr) {
                        result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
                    }
                    else {
                        result = res.data.slice(0, this.limit);
                    }
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.count, //解析数据长度
                        "data": result //解析数据列表
                    };
                }
                ,cols: [[ //表头
                    {type:"checkbox",fixed: "left"}
                    /*,{type:"numbers"}*/
                    ,{field: 'paperId', title: '试卷编号', fixed: 'left'}
                    ,{field: 'classId', title: '班级编号'}
                    ,{field: 'examDate', title: '考试日期'}
                    ,{field: 'beginTime', title: '考试开始时间'}
                    ,{field: 'finishTime', title: '考试结束日期'}
                    ,{fixed: 'right', title:'操作', toolbar: '#barDemo',align:'center'}
                ]]
                ,page:true
            });

            //绑定监听事件
            table.on("tool(test)",function(rel){

                layer.confirm('您确定进入考试吗？', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    layer.msg('现在开始考试', {icon: 1});
                    top.location.href="ForeExam.jsp";
                }, function(){
                    layer.msg('你已取消', {
                        time: 2000, //20s后自动关闭
                    });
                });
            });


        });


    </script>

</body>
</html>